<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * App\CourseQuestionAnswerRecord
 *
 * @property int $id
 * @property int $user_id 答题用户id
 * @property int $course_id 课程id
 * @property int $course_question_id 问题id
 * @property string $course_question_option_id_arr 选项id
 * @property int $is_bingo 答对了
 * @property \Illuminate\Support\Carbon|null $deleted_at
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @method static bool|null forceDelete()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseQuestionAnswerRecord newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseQuestionAnswerRecord newQuery()
 * @method static \Illuminate\Database\Query\Builder|\App\CourseQuestionAnswerRecord onlyTrashed()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseQuestionAnswerRecord query()
 * @method static bool|null restore()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseQuestionAnswerRecord whereCourseId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseQuestionAnswerRecord whereCourseQuestionId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseQuestionAnswerRecord whereCourseQuestionOptionIdArr($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseQuestionAnswerRecord whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseQuestionAnswerRecord whereDeletedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseQuestionAnswerRecord whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseQuestionAnswerRecord whereIsBingo($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseQuestionAnswerRecord whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseQuestionAnswerRecord whereUserId($value)
 * @method static \Illuminate\Database\Query\Builder|\App\CourseQuestionAnswerRecord withTrashed()
 * @method static \Illuminate\Database\Query\Builder|\App\CourseQuestionAnswerRecord withoutTrashed()
 * @mixin \Eloquent
 */
class CourseQuestionAnswerRecord extends Model
{
    use SoftDeletes;

    public static function addRecord($user_id = 0,$course_id = 0,$question_id = 0,$option_ids = [],$is_bingo = 0){
        $record                     = new self();
        $record->user_id            = $user_id ?? 0;
        $record->course_id          = $course_id ?? 0;
        $record->course_question_id = $question_id ?? 0;
        $record->course_question_option_id_arr = $option_ids ? json_encode($option_ids) : '';
        $record->is_bingo           = $is_bingo ?? 0;
        $record->save();
    }
}
